﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="BlogDH.User.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../Css/usercenter.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div class="container">
        <div class="header">
            <a href="">博客导航</a>
        </div>
        <div class="main">
            <div class="left">
                <ul>
                    <li><a href="javascript:void(0);">个人信息</a></li>
                    <li><a href="changepwd.aspx">密码修改</a></li>
                    <li><a href="bloginfo.aspx">博客信息</a></li>
                </ul>
            </div>
            <div class="right">
                <form id="form1" method="post" action="Index.aspx">
                <p>
                    <label>
                        邮箱：</label>
                    <input type="text" id="email" value="<%=userinfo.email %>" name="email" onblur="CheckMail()" /><span
                        class="error" id="emailErr"><%=errEmail %></span>
                </p>
                <p>
                    <label>
                        手机号：</label>
                    <input type="text" id="phone" value="<%=userinfo.phone %>" name="phone" onblur="CheckPhone()" /><span
                        class="error" id="phoneErr"><%=errPhone %></span></p>
                <p>
                    <label>
                        居住地：</label>
                    <select id="sheng">
                        <option value='0'>选择省</option>
                        <%=GetSheng() %>
                    </select>
                    <select id="shi">
                        <option value='0'>选择市</option>
                        <%=GetShi() %>
                    </select>
                    <select id="xian">
                        <option value='0'>选择县</option>
                        <%=GetXian() %>
                    </select><span class="error" id="areaErr">
                        <%=errArea %></span></p>
                <input type="submit" class="button" name="commit" value="保存" onclick=" return gosubmit()" />
                <input type="hidden" id="areaid1" name="areaid1" value="<%=userinfo.Sheng %>" />
                <input type="hidden" id="areaid2" name="areaid2" value="<%=userinfo.Shi %>" />
                <input type="hidden" id="areaid3" name="areaid3" value="<%=userinfo.Xian %>" />
                </form>
            </div>
        </div>
        <div class="footer">
        </div>
    </div>
    <script src="../Script/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#sheng").change(function () {
                var id = $(this).find("option:selected").val();
                setarea(id, "shi", "选择市");
                $("#xian").html("<option selected=\"true\">选择县</option>");
                $("#areaid1").val(id);
            });
            $("#shi").change(function () {
                var id = $(this).find("option:selected").val();
                setarea(id, "xian", "选择县");
                $("#areaid2").val(id);
            });
            $("#xian").change(function () {
                var id = $(this).find("option:selected").val();
                $("#areaid3").val(id);
            });
        });

        function setarea(id, type, info) {
            var obj = $("#" + type);
            if (id != "0") {
                obj.empty();
                $('<option value=\'0\'> ' + info + '</option>').appendTo(obj);
                $.getJSON('/ajax/getarea.ashx?id=' + id + "&type=" + type,
            function (t) {
                $.each(t,
                function (i) {
                    $('<option value=' + t[i].id + '>' + t[i].name + '</option>').appendTo(obj);
                }); obj.click();
            });
            }
            else {
                obj.html("<option selected=\"true\">" + info + "</option>");
                obj.click();
            }
        }

        function gosubmit() {
            var ret = false;
            if (CheckMail() && CheckPhone()) {
                ret = true;
            }
            if (document.getElementById("xian").selectedIndex <= 0) {
                document.getElementById("areaErr").innerHTML = "*";
                ret = false;
            }
            return ret;
        }

        function CheckMail() {
            var ret = false;
            var mail = document.getElementById("email").value;
            var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            if (mail == "") {
                document.getElementById("emailErr").innerHTML = "*";
            } else if (filter.test(mail)) {
                document.getElementById("emailErr").innerHTML = "";
                ret = true;
            } else {
                document.getElementById("emailErr").innerHTML = "邮箱格式错误";
            }
            return ret;
        }
        function CheckPhone() {
            var ret = false;
            var mail = document.getElementById("phone").value;
            var filter = /^0?(13[0-9]|15[012356789]|18[0236789]|14[57])[0-9]{8}$/;
            if (mail == "") {
                document.getElementById("phoneErr").innerHTML = "*";
            } else if (filter.test(mail)) {
                document.getElementById("phoneErr").innerHTML = "";
                ret = true;
            } else {
                document.getElementById("phoneErr").innerHTML = "手机号格式错误";
            }
            return ret;
        }
    </script>
</body>
</html>
